<?php 
/**
 * 利用系统函数对数组进行排序
 */
	//sort() 元素按数字进行升序排序：
	//rsort() 元素按数字进行降序排序：
	$arr1 = array(1, 2, 3, 4, 5, 43, 44, 76,6, 7, 8, 9, 10);
	sort($arr1);
	print_r($arr1);
	echo "<br>";

	rsort($arr1);
	print_r($arr1);
	echo "<br>";
	echo "<hr>";

	$arr2 = array("one", "two", "three", "four", "five");
	sort($arr2);
	print_r($arr2);
	echo "<br>";

	rsort($arr2);
	print_r($arr2);
	echo "<br>";
	echo "<hr>";

	//ksort() 按照键名进行升序排序
	//krsort() 按照键名进行降序排序
	$arr3 = array(1=>"linux", 6=>"Apache", 2=>"MySQL", 5=>"PHP");
	ksort($arr3);
	print_r($arr3);
	echo "<br>";

	krsort($arr3);
	print_r($arr3);
	echo "<br>";
	echo "<hr>";

	$arr4 = array("l"=>"linux", "A"=>"Apache", "M"=>"MySQL", "P"=>"PHP");
	ksort($arr4);
	print_r($arr4);
	echo "<br>";

	krsort($arr4);
	print_r($arr4);
	echo "<br>";
	echo "<hr>";

	//asort() 按照键名进行升序排序并保持索引关系
	//arsort() 按照键名进行降序排序并保持索引关系
	$arr3 = array(1=>"linux", 6=>"Apache", 2=>"MySQL", 5=>"PHP");
	ksort($arr3);
	print_r($arr3);
	echo "<br>";

	krsort($arr3);
	print_r($arr3);
	echo "<br>";
	echo "<hr>";

	$arr4 = array("l"=>"linux", "A"=>"Apache", "M"=>"MySQL", "P"=>"PHP");
	ksort($arr4);
	print_r($arr4);
	echo "<br>";

	krsort($arr4);
	print_r($arr4);
	echo "<br>";
	echo "<hr>";

	//natsort() 用"自然排序"算法对数组排序
	//natcasesort() 自然排序算法最数组i进行不区分大小写字母的排序
	
	$arr5 = array("file1.txt", "file3.txt", "FILE.txt", "file.txt");
	natsort($arr5);
	print_r($arr5);
	echo "<br>";

	natcasesort($arr5);
	print_r($arr5);
	echo "<br>";
	echo "<hr>";

 ?>